﻿#include "enemytank.h"
EnemyTank::EnemyTank(QWidget* parent, QString name) : Sprite(parent, name)
{
    this->setFixedSize(pixmap->size()*0.2);
    QVBoxLayout *layout=new QVBoxLayout(this);
    this->widget->setLayout(layout);
    layout->addWidget(closeButton);
    connect(closeButton,&QPushButton::clicked,[=](){
        this->isExist=false;
    });
}

EnemyTank::~EnemyTank()
{
    deleteResouce();
}
void EnemyTank::mousePressEvent(QMouseEvent *event)
{
    if(!this->widget->isVisible())
        this->widget->show();
    else  this->widget->hide();
    QPushButton::mousePressEvent(event);
    //qDebug()<<"you have push the button";
}
void EnemyTank::deleteResouce()
{
    if (pixmap)
        delete pixmap;

    if (closeButton)
        delete closeButton;

    if (widget)
        delete widget;
}
